import sys
import numpy

# compare result of python program and that of matlab
# example:read in npy created by build_spec.py  and compare against the result by matlab

if len(sys.argv)<3:
    print('usage:')
    sys.exit(0)

npy = sys.argv[1]

# 98*50
txt = sys.argv[2]
py = numpy.load(npy)
print(py.shape)

matlab = numpy.loadtxt(txt)
print(matlab.shape)

diff= py-matlab
sqr = diff **2

sum = numpy.sum(sqr.reshape(1,-1))
print("sum:%f"%sum)
abs=numpy.abs(diff.reshape(1,-1))
max = numpy.max(abs)
total=numpy.sum(numpy.where(abs>0.9,1,0))
#print(abs[0:100])
print("max:%f"%max)
print("total > 0.1 :%d"%total)
#print(py[0:100])
